﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIA.Integration;
using VIA.Integration.Alarms;
using VIA.Integration.Automatics;

namespace VIA.Project.Domain.Devices
{
    public class VirtualPLC : IPLC
    {
        public string Desc { get; set; }
        public string Id { get; set; }
        public string Name { get; set; }
        public IPart Owner { get; set; }
        public IList<StatusAlarm> StatusAlarms { get; }
        public IRecipeProvider Recipe { get; }
        public bool IsConnected { get; private set; } = true;

        public event Action<IDevice> IsConnectedChanged;

        public void Connect()
        {
            IsConnected = true;
        }

        public void Disconnect()
        {
        }

        public Task<byte[]> ReadAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<bool> ReadBoolAsync(string address)
        {
            throw new NotImplementedException();
        }

        public Task<bool[]> ReadBoolAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public bool ReadBoolean(string address)
        {
            return true;
        }

        public bool[] ReadBoolean(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public byte ReadByte(string address)
        {
            throw new NotImplementedException();
        }

        public byte[] ReadByte(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public double ReadDouble(string address)
        {
            return 1.0;
        }

        public double[] ReadDouble(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<double> ReadDoubleAsync(string address)
        {
            throw new NotImplementedException();
        }

        public Task<double[]> ReadDoubleAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public float ReadFloat(string address)
        {
            throw new NotImplementedException();
        }

        public float[] ReadFloat(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<float> ReadFloatAsync(string address)
        {
            throw new NotImplementedException();
        }

        public Task<float[]> ReadFloatAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public int ReadInt(string address)
        {
            return 0;
        }

        public int[] ReadInt(string address, ushort length)
        {
            return new int[] { 0 };
        }

        public Task<short> ReadInt16Async(string address)
        {
            TaskCompletionSource<short> taskCompletionSource=new TaskCompletionSource<short>();
            taskCompletionSource.SetResult((short)0);
            return taskCompletionSource.Task;
        }

        public Task<short[]> ReadInt16Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<int> ReadInt32Async(string address)
        {
            throw new NotImplementedException();
        }

        public Task<int[]> ReadInt32Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<long> ReadInt64Async(string address)
        {
            throw new NotImplementedException();
        }

        public Task<long[]> ReadInt64Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public long ReadLong(string address)
        {
            throw new NotImplementedException();
        }

        public long[] ReadLong(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public short ReadShort(string address)
        {
            return 0;
        }

        public short[] ReadShort(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public string ReadString(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<string> ReadStringAsync(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<string> ReadStringAsync(string address, ushort length, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        public uint ReadUInt(string address)
        {
            throw new NotImplementedException();
        }

        public uint[] ReadUInt(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<ushort> ReadUInt16Async(string address)
        {
            throw new NotImplementedException();
        }

        public Task<ushort[]> ReadUInt16Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<uint> ReadUInt32Async(string address)
        {
            throw new NotImplementedException();
        }

        public Task<uint[]> ReadUInt32Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public Task<ulong> ReadUInt64Async(string address)
        {
            throw new NotImplementedException();
        }

        public Task<ulong[]> ReadUInt64Async(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public ulong ReadULong(string address)
        {
            throw new NotImplementedException();
        }

        public ulong[] ReadULong(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public ushort ReadUShort(string address)
        {
            return 1;
        }

        public ushort[] ReadUShort(string address, ushort length)
        {
            throw new NotImplementedException();
        }

        public void Write(string address, bool value)
        {
            return;
        }

        public void Write(string address, bool[] values)
        {
            return;
        }

        public void Write(string address, byte value)
        {
            return;
        }

        public void Write(string address, byte[] values)
        {
            return;
        }

        public void Write(string address, short value)
        {
            return;
        }

        public void Write(string address, short[] values)
        {
            return;
        }

        public void Write(string address, ushort value)
        {
            return;
        }

        public void Write(string address, ushort[] values)
        {
            return;
        }

        public void Write(string address, int value)
        {
            return;
        }

        public void Write(string address, int[] values)
        {
            return;
        }

        public void Write(string address, uint value)
        {
            return;
        }

        public void Write(string address, uint[] values)
        {
            return;
        }

        public void Write(string address, long value)
        {
            return;
        }

        public void Write(string address, long[] values)
        {
            return;
        }

        public void Write(string address, ulong value)
        {
            return;
        }

        public void Write(string address, ulong[] values)
        {
            return;
        }

        public void Write(string address, float value)
        {
            return;
        }

        public void Write(string address, float[] values)
        {
            return;
        }

        public void Write(string address, double value)
        {
            return;
        }

        public void Write(string address, double[] values)
        {
            return;
        }

        public void Write(string address, string value)
        {
            return;
        }

        public void Write(string address, string value, int length)
        {
            return;
        }

        public Task WriteAsync(string address, byte[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, bool[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, bool value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, short value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, short[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, ushort value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, ushort[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, int value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, int[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, uint value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, uint[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, long value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, long[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, ulong value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, ulong[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, float value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, float[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, double value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, double[] values)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, string value)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, string value, Encoding encoding)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, string value, int length)
        {
            return Task.CompletedTask;
        }

        public Task WriteAsync(string address, string value, int length, Encoding encoding)
        {
            return Task.CompletedTask;
        }
    }
}
